﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Authors
{
    /// <summary>
    /// An additional result field that provides information about a category an author has a book about.    
    /// </summary>
    public sealed class AuthorElementCategory : ResponseElementChildBase
    {
        #region Constructor + Overridden Properties

        /* Element Details:
            <Category category_id="alphabetically.authors.a.n">N</Category>
         */

        /// <summary>
        /// Initializes a new instance of the <see cref="AuthorElementCategory"/> class.
        /// </summary>
        /// <param name="element">The xml element that contains the underlying data for this instance.</param>
        public AuthorElementCategory(XmlElement element)
            : base(element) { }

        /// <summary>
        /// Gets the element name that is expected by this element's constructor.
        /// </summary>
        protected override string ExpectedElementName
        {
            get { return "Category"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Gets the id that uniquely-represents this category to the ISBNDB.com api.
        /// </summary>
        public string CategoryId
        {
            get { return _element.Attributes["category_id"].Value; }
        }

        /// <summary>
        /// Gets the free-form text that represents this category.
        /// </summary>
        public string Text
        {
            get { return _element.InnerText; }
        }

        #endregion
    }
}
